enum loop

51

enum loop -

enum Foos {
  Foo,
  Bar,
}

foreach(Foos val in Enum.GetValues(typeof(Foos))) {
  //Do whatever with the value :D
}

loop over enum values -

var values = Enum.GetValues(typeof(EnumName));

foreach (var value in values)
{
	Combobox.Items.Add(value.ToString());
}

Comments

Submit
0 Comments